package com.two.commodityorder.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.two.commodityorder.service.CommodityService;
import com.two.commodityorder.service.impl.CommodityServiceImpl;
@WebServlet("/loginCommodityServlet.do")
public class LoginCommodityServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String commodityName = req.getParameter("commodityName");
		CommodityService service = new CommodityServiceImpl();
		boolean result = service.selectByCommodityName(commodityName);
		PrintWriter pw = resp.getWriter();
		pw.append(String.valueOf(result));
		pw.flush();
		pw.close();
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
